{extend name="$member_style_layout" /}

{block name="title"}短消息{/block}
{block name="content"}
{include file="msg/menu" /}
<style>
.ListContainer{
	min-height:700px;
}
.CommentList{
	border-top:#DDD solid 1px;
	border-bottom:#DDD solid 1px;
	margin:10px auto;
	background:#FFF;
	font-size:14px;
}
.CommentList .title{
	padding:5px 10px;
	line-height:20px;
}
.CommentList .info .UserTime{
	height:20px;
	line-height:20px;
	padding:0 10px;
	overflow:hidden;
	text-align:right;
	color:#999;
}
.CommentList .info .UserTime .userL{
	float:left;
}
.CommentList .info .UserTime .timeR{
	float:right;
}
.CommentList .info .CommentSubmits{
	border-top:#DDD dotted 1px;
	text-align:center;
	padding:0 5px 5px 5px;
	margin-top:5px;
}
.CommentList .info .CommentSubmits a{
	display:inline-block;
	line-height:25px;
	padding:0 10px;
	border:#DDD solid 1px;
	margin:5px 5px 0 5px;
	color:#666;
}
.read_menu{
	padding-left:10px;
}
</style>
<script>$('.fa-envelope').addClass('blue');</script>
<div class="read_menu"><button class="layui-btn layui-btn-primary layui-btn-sm" onclick="choosebox($(this))">全选</button> <button class="layui-btn layui-btn-sm" onclick="set_readed()">标志为已读</button></div>
<div class="ListContainer">	 
{volist name="listdb" id="rs"}
    <div class='CommentList'>
		<div class='title'>
			<input type="checkbox" name="ids[]" value="{$rs.id}"> <a href="{:urls('show',['id'=>$rs['id']])}">{$rs.title}</a>
		</div>
		<div class='info'>
			<div class='UserTime'><span class='userL'>
	发件人：<a href="{:get_url('user',['uid'=>$rs['uid']])}" target="_blank">{$rs.from_username}</a>
			</span><span class='timeR'>{$rs.create_time}</span></div>
			<div class='CommentSubmits'><span class='state'>
	{eq name="$rs.ifread" value="0"}
			<span style='color:red;'>未读</span>
	{else /}
	已读
	{/eq}</span> <a href="{:urls('delete',['id'=>$rs['id']])}">删除</a> <a href="{:urls('add',['username'=>$rs['from_username']])}">回复</a></div>                
		</div>
    </div>
{/volist}
	<div class="Showpage">{$pages}</div>
</div>

<script type="text/javascript">
//全选
var choose_all = false;
function choosebox(that){
	choose_all = choose_all?false:true;
	that.html(choose_all? '取消' : '全选');
	$("input[name='ids[]']").each(function(){
		$(this).prop("checked",choose_all?true:false);
	});
}
//标志为已读
function set_readed(){
	if($("input[name='ids[]']:checked").length<1){
		layer.alert('请至少选择一项');
		return false;
	}
	str = '';
	$("input[name='ids[]']:checked").each(function(){
		str += 'ids[]=' + $(this).val() + '&';
	});
	var url = "{:url('wxapp.msg/set_read')}?"+str;
	$.get(url,function(res){
		if(res.code==0){
			window.location.reload();
		}else{
			layer.alert(res.msg);
		}
	});
}
</script>

{/block}